using System.Collections.Generic;
using UnityEngine;

[CreateAssetMenu(fileName = "SavedData", menuName = "SavedData", order = 1)]
public class SavedData : ScriptableObject
{
    private Dictionary<int, CheckPoint> _CP_Reg;
    private int _lastTouhedCPKey;
    public bool _isINIed;

    public void Initialize()
    {
        _isINIed = false;
        _CP_Reg = new Dictionary<int, CheckPoint>();
        _lastTouhedCPKey = -1;
    }

    public void Reg_CPs(int key, CheckPoint CP)
    {
        _CP_Reg.Add(key, CP);
    }

    public void Save(int key)
    {
        _lastTouhedCPKey = key;
    }

    public void Load()
    {
        if (_isINIed && _lastTouhedCPKey != -1)
        {
            //[ATTENTION]
            MainRole.Instance.gameObject.transform.position = _CP_Reg[_lastTouhedCPKey]._respawnPoint.transform.position;//reset position
            AirCurtain.Instance.Load(_CP_Reg[_lastTouhedCPKey]._savedHeight, _CP_Reg[_lastTouhedCPKey]._savedSpeed);//reset height
        }
    }
}
